<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');


$time = $_GET['time'];


$searchDate = $_GET['start_date'];
$getDateArray = array();
if( preg_match("#/#", $searchDate) ){
	$getDateArray = explode("/", $searchDate);
}else if( preg_match("#-#", $searchDate) ){
	$getDateArray = explode("-", $searchDate);
}else{
	array_push($getDateArray, substr($searchDate, 0, 4));
	array_push($getDateArray, substr($searchDate, 4, 2));
	array_push($getDateArray, substr($searchDate, 6, 2));
}

$time['startYear'] = $getDateArray[0];
$time['startMonth'] = $getDateArray[1];
$time['startDay'] = $getDateArray[2];

$searchDate = $_GET['end_date'];
$getDateArray = array();
if( preg_match("#/#", $searchDate) ){
	$getDateArray = explode("/", $searchDate);
}else if( preg_match("#-#", $searchDate) ){
	$getDateArray = explode("-", $searchDate);
}else{
	array_push($getDateArray, substr($searchDate, 0, 4));
	array_push($getDateArray, substr($searchDate, 4, 2));
	array_push($getDateArray, substr($searchDate, 6, 2));
}

$time['endYear'] = $getDateArray[0];
$time['endMonth'] = $getDateArray[1];
$time['endDay'] = $getDateArray[2];



$tmp_date=date("Ymd");
$tmp_year=substr($tmp_date,0,4) * 1;
$tmp_mon =substr($tmp_date,4,2) * 1;
$tmp_day = substr($tmp_date, 6, 2) * 1;

$time['startYear'] = $time['startYear'] > 0 ? $time['startYear'] : $tmp_year;
$time['startMonth'] = $time['startMonth'] > 0 ? $time['startMonth'] : $tmp_mon;
$time['startDay'] = $time['startDay'] > 0 ? $time['startDay'] : $tmp_day;
$time['endYear'] = $time['endYear'] > 0 ? $time['endYear'] : $tmp_year;
$time['endMonth'] = $time['endMonth'] > 0 ? $time['endMonth'] : $tmp_mon;
$time['endDay'] = $time['endDay'] > 0 ? $time['endDay'] : $tmp_day;

$userList = Users::GetAll();
$bookedList = array();
foreach($userList as $k => $v){
	$tempList = Preengage::GetListByUserId($v['id'], $time['startYear'], $time['startMonth'], $time['startDay'], $time['endYear'], $time['endMonth'], $time['endDay']);
	 $bookedList[$v['id']] = $tempList;
}


include template('/service/vip_status');


//include template('service_staff_index');
//include template('subscribe');
